package cn.huchao.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author huchao
 * @date 2018/7/27
 * @description
 */
@Aspect
@Component
public class RequestAspect {
    /**
     * Pointcut定义切点
     *
     */
    //@Pointcut("execution(public * cn.huchao.controller.*.*(..))")//public修饰符的   返回值任意  包下面的任意类的任意方法任意参数
    @Pointcut("@annotation(cn.huchao.aspect.LogFactory)")
    public void log(){

    }

    @Before("log()")
    public void doBefore(JoinPoint joinPoint){

        System.out.println("方法执行前");

    }

    @After("log()")
    public void doAfter(JoinPoint joinPoint){
        System.out.println("方法执行后...");
    }

    @AfterReturning(returning="result", pointcut="log()")
    public void doAfterReturnint(Object result){
        System.out.println("方法返回值：" + result);
    }
}
